# Maintainer: Michael Zhou <zhoumichaely@gmail.com>
pkgname=vde2
pkgver=2.3.3
pkgrel=3
pkgdesc="VDE: Virtual Distributed Ethernet. User mode networking for QEMU, UML, etc."
url="https://github.com/virtualsquare/vde-2"
arch="all"
options="!check"  # No test suite.
license="GPL"
install="vde2.pre-install"
makedepends="autoconf automake libtool linux-headers wolfssl-dev libpcap-dev python3-dev"
subpackages="$pkgname-doc $pkgname-dev $pkgname-libs"
source="$pkgname-$pkgver.tar.gz::https://github.com/virtualsquare/vde-2/archive/refs/tags/v$pkgver.tar.gz
	musl-build-fix.patch

	vde2.pre-up
	vde2.post-down
	"
builddir="$srcdir"/vde-2-$pkgver

prepare() {
	default_prepare

	autoreconf -fiv
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc
	make -C src/common
	make -C src/lib
	make
}

package() {
	make DESTDIR="$pkgdir" install

	install -Dm755 "$srcdir"/vde2.pre-up \
		"$pkgdir"/etc/network/if-pre-up.d/vde2
	install -Dm755 "$srcdir"/vde2.post-down \
		"$pkgdir"/etc/network/if-post-down.d/vde2
}

libs() {
	pkgdesc="Virtual Distributed Ethernet libraries"
	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/lib*.so.* "$subpkgdir"/usr/lib/
}

sha512sums="
d0495aa700984dcc82f85cf7c8125cc10505a8a077fceec45b7fd2bec9c389966381682842e886469fa49239badd9442403d091c2ae5282685085e8262396387  vde2-2.3.3.tar.gz
f3a8bfd0648d66bf7bce65c67d312774ed2413532700935b06acd9bed851f1e2529194c9a4d748d9cb37327e005cb942feeb964f48a32a0e19e6062a5d374b54  musl-build-fix.patch
71b29d538bba80b881f239d683215279089c14e8feec05bf27c159ead51094cdfb168281900fa4527f588c624e8f7687df8d3f79377e07d13ad64de613177df3  vde2.pre-up
d1cf18146145dbe608842c694b05d2906e36553b0ba3fa1ec2e53dbf06027b9e4937ea61aee77c1ccbb73b818f19d55787051eb6d5b09a38c7d18a1dad629190  vde2.post-down
"
